<html>
<head><meta charset="utf-8"><title>Difference between HIR and the rustdoc IR · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html">Difference between HIR and the rustdoc IR</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220862178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220862178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220862178">(Dec 24 2020 at 10:44)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> : I saw you submitted several PRs which reduce the amount of data in the rustdoc IR.<br>
Sorry if this is a silly question: why doesn't rustdoc use the HIR directly?</p>



<a name="220866528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220866528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220866528">(Dec 24 2020 at 12:22)</a>:</h4>
<p>We need data to be formatted (or "cleaned" haha) to then be able to render the docs. We need to do it on top of HIR. However, we are now removing more and more of those cleanups to move it where we need them instead of doing it for everything by default. I hope that answers your question?</p>



<a name="220870603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220870603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220870603">(Dec 24 2020 at 13:43)</a>:</h4>
<p><span class="user-mention" data-user-id="248906">@cjgillot</span> IMO it should just use the HIR</p>



<a name="220870607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220870607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220870607">(Dec 24 2020 at 13:43)</a>:</h4>
<p>But most of this was written in 2013 by one guy and people just wanted something that worked</p>



<a name="220870675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220870675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220870675">(Dec 24 2020 at 13:44)</a>:</h4>
<p>But yeah if you look at the doctree PRs most of them are getting rid of the IR in favor of using hir directly</p>



<a name="220896486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896486">(Dec 24 2020 at 23:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR/near/220870607">said</a>:</p>
<blockquote>
<p>But most of this was written in 2013 by one guy and people just wanted something that worked</p>
</blockquote>
<p>Looks like this PR was where rustdoc was introduced: <a href="https://github.com/rust-lang/rust/issues/1360">#1360</a>. Just over 9 years ago, and only 200 lines of code! Rust looked so different back then.</p>



<a name="220896507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896507">(Dec 24 2020 at 23:45)</a>:</h4>
<p>This is how imports and type definitions looked:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">use</span><span class="w"> </span><span class="n">std</span><span class="p">;</span><span class="w"></span>
<span class="k">use</span><span class="w"> </span><span class="n">rustc</span><span class="p">;</span><span class="w"></span>

<span class="n">import</span><span class="w"> </span><span class="n">option</span><span class="p">;</span><span class="w"></span>
<span class="n">import</span><span class="w"> </span><span class="n">option</span>::<span class="p">{</span><span class="n">some</span><span class="p">,</span><span class="w"> </span><span class="n">none</span><span class="p">};</span><span class="w"></span>
<span class="n">import</span><span class="w"> </span><span class="n">rustc</span>::<span class="n">syntax</span>::<span class="n">ast</span><span class="p">;</span><span class="w"></span>
<span class="n">import</span><span class="w"> </span><span class="n">rustc</span>::<span class="n">syntax</span>::<span class="n">codemap</span><span class="p">;</span><span class="w"></span>
<span class="n">import</span><span class="w"> </span><span class="n">rustc</span>::<span class="n">syntax</span>::<span class="n">parse</span>::<span class="n">parser</span><span class="p">;</span><span class="w"></span>
<span class="n">import</span><span class="w"> </span><span class="n">rustc</span>::<span class="n">syntax</span>::<span class="n">print</span>::<span class="n">pprust</span><span class="p">;</span><span class="w"></span>
<span class="n">import</span><span class="w"> </span><span class="n">rustc</span>::<span class="n">syntax</span>::<span class="n">visit</span><span class="p">;</span><span class="w"></span>
<span class="n">import</span><span class="w"> </span><span class="n">std</span>::<span class="n">io</span><span class="p">;</span><span class="w"></span>
<span class="n">import</span><span class="w"> </span><span class="n">std</span>::<span class="n">map</span><span class="p">;</span><span class="w"></span>

<span class="k">type</span> <span class="nc">rustdoc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">ps</span>: <span class="nc">pprust</span>::<span class="n">ps</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">w</span>: <span class="nc">io</span>::<span class="n">writer</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>

<span class="k">type</span> <span class="nc">fndoc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">brief</span>: <span class="kt">str</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">desc</span>: <span class="nc">option</span>::<span class="n">t</span><span class="o">&lt;</span><span class="kt">str</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">return</span>: <span class="nc">option</span>::<span class="n">t</span><span class="o">&lt;</span><span class="kt">str</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">args</span>: <span class="nc">map</span>::<span class="n">hashmap</span><span class="o">&lt;</span><span class="kt">str</span><span class="p">,</span><span class="w"> </span><span class="kt">str</span><span class="o">&gt;</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>
</code></pre></div>



<a name="220896620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896620">(Dec 24 2020 at 23:48)</a>:</h4>
<p>that's the original rustdoc</p>



<a name="220896634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896634">(Dec 24 2020 at 23:49)</a>:</h4>
<p>the current rustdoc was originally called 'rustdoc_ng' <a href="https://github.com/rust-lang/rust/pull/9402">https://github.com/rust-lang/rust/pull/9402</a></p>



<a name="220896685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896685">(Dec 24 2020 at 23:50)</a>:</h4>
<p>Ah, really? I was using GitHub to navigate the history of <code>src/librustdoc/lib.rs</code>, so I might have made a mistake and missed that.</p>



<a name="220896688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896688">(Dec 24 2020 at 23:50)</a>:</h4>
<p>github doesn't follow file renames</p>



<a name="220896693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896693">(Dec 24 2020 at 23:50)</a>:</h4>
<p>Yes, I was manually going to the end of the history and then finding the file it was renamed from and continuing on.</p>



<a name="220896694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896694">(Dec 24 2020 at 23:50)</a>:</h4>
<p>here's the original commit: <a href="https://github.com/rust-lang/rust/commit/268f3f0ff5d80544ca21d565354eae6d3e29fb91">https://github.com/rust-lang/rust/commit/268f3f0ff5d80544ca21d565354eae6d3e29fb91</a></p>



<a name="220896697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896697">(Dec 24 2020 at 23:51)</a>:</h4>
<p>ah ok I found the issue - <a href="http://lib.rs">lib.rs</a> exists in both rustdoc_ng and the original</p>



<a name="220896700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896700">(Dec 24 2020 at 23:51)</a>:</h4>
<p>if you follow <a href="http://core.rs">core.rs</a> instead it works</p>



<a name="220896714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Difference%20between%20HIR%20and%20the%20rustdoc%20IR/near/220896714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Difference.20between.20HIR.20and.20the.20rustdoc.20IR.html#220896714">(Dec 24 2020 at 23:51)</a>:</h4>
<p>Ah, the old squiggly <code>Box</code> :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>